﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Resources.Core;
using Windows.Foundation.Collections;

namespace UnitDriven
{
    public sealed class Properties : ObservableObject
    {
        private static Lazy<Properties> resources = new Lazy<Properties>(() => new Properties());

        public static Properties Resources
        {
            get { return resources.Value; }
        }

        private Properties()
        {
            ResourceManager.Current.DefaultContext.QualifierValues.MapChanged += OnMapChanged;
        }

        private static string GetString(Expression<Func<object>> property)
        {
            var name = ((MemberExpression)property.Body).Member.Name;
            return ResourceManager.Current.MainResourceMap.GetValue("UnitDrivenRT/resources/" + name).ValueAsString;
        }

        private void OnMapChanged(IObservableMap<string, string> sender, IMapChangedEventArgs<string> @event)
        {
            this.UpdateAll();
        }

        public string AssertAreEqualFailed
        {
            get { return GetString(() => AssertAreEqualFailed); }
        }

        public string AssertAreNotEqualFailed
        {
            get { return GetString(() => AssertAreNotEqualFailed); }
        }

        public string AssertAreNotSameFailed
        {
            get { return GetString(() => AssertAreNotSameFailed); }
        }

        public string AssertAreSameFailed
        {
            get { return GetString(() => AssertAreSameFailed); }
        }

        public string AssertFail
        {
            get { return GetString(() => AssertFail); }
        }

        public string AssertIsFalseFailed
        {
            get { return GetString(() => AssertIsFalseFailed); }
        }

        public string AssertIsInstanceOfTypeFailed
        {
            get { return GetString(() => AssertIsInstanceOfTypeFailed); }
        }

        public string AssertIsNotEmptyFailed
        {
            get { return GetString(() => AssertIsNotEmptyFailed); }
        }

        public string AssertIsNotInstanceOfTypeFailed
        {
            get { return GetString(() => AssertIsNotInstanceOfTypeFailed); }
        }

        public string AssertIsNotNullFailed
        {
            get { return GetString(() => AssertIsNotNullFailed); }
        }

        public string AssertIsNullFailed
        {
            get { return GetString(() => AssertIsNullFailed); }
        }

        public string AssertIsTrueFailed
        {
            get { return GetString(() => AssertIsTrueFailed); }
        }

        public string AsyncAssertAreEqualFailed
        {
            get { return GetString(() => AsyncAssertAreEqualFailed); }
        }

        public string AsyncAssertAreSameFailed
        {
            get { return GetString(() => AsyncAssertAreSameFailed); }
        }

        public string AsyncAssertFail
        {
            get { return GetString(() => AsyncAssertFail); }
        }

        public string AsyncAssertIsFalseFailed
        {
            get { return GetString(() => AsyncAssertIsFalseFailed); }
        }

        public string AsyncAssertIsNotNullFailed
        {
            get { return GetString(() => AsyncAssertIsNotNullFailed); }
        }

        public string AsyncAssertIsNullFailed
        {
            get { return GetString(() => AsyncAssertIsNullFailed); }
        }

        public string AsyncAssertIsTrueFailed
        {
            get { return GetString(() => AsyncAssertIsTrueFailed); }
        }

        public string ExpectedExceptionDoesNotInheritFromException
        {
            get { return GetString(() => ExpectedExceptionDoesNotInheritFromException); }
        }
    }
}
